<template>
  <footer class="footer">
    <span class="todo-count">剩余<strong>{{Count}}</strong></span>
    <ul class="filters">
      <li>
        <a @click="$emit('change2','all')" :class="{selected:type==='all'}" href="javascript:;" >全部</a>
      </li>
      <li>
        <a @click="$emit('change2','no')" :class="{selected:type==='no'}" href="javascript:;">未完成</a>
      </li>
      <li>
        <a @click="$emit('change2','yes')" :class="{selected:type==='yes'}" href="javascript:;" >已完成</a>
      </li>
    </ul>
    <button class="clear-completed" v-show="clearkk" @click="clear">清除已完成</button>
  </footer>
</template>

<script>
export default {
  props:{list:{type:true,required:true},type:String},
  computed:{
    Count() {
      return this.list.length ? this.list.filter(item=>!item.isDone).length : 0
    },
    clearkk() {
      return this.list.some(item=>!item.isDone)
    }
  },
  methods:{
    clear() {
      this.$emit('clear')
    }
  }
}
</script>